/*
 * @lc app=leetcode.cn id=832 lang=javascript
 *
 * [832] 翻转图像
 */

// @lc code=start
/**
 * @param {number[][]} A
 * @return {number[][]}
 */
var flipAndInvertImage = function (A) {
  for (let i = 0; i < A.length; i++) {
    let l = 0;
    r = A[i].length - 1;
    while (l < r) {
      if (A[i][l] === A[i][r]) {
        A[i][l] = A[i][r] = !A[i][l];
      }
      l++;
      r--;
    }
    if (l == r) {
      A[i][l] = !A[i][l];
    }
  }
  return A;
};
// @lc code=end

let rotate = function (arr) {
  let a = arr.length;
  let b = arr[0].length;
  let res = new Array(b);
  for (let i = 0; i < b; i++) {
    res[i] = [];
    for (let j = 0; j < a; j++) {
      res[i][j] = arr[j][i];
    }
  }
  return res;
};
console.log(rotate([[1, 2]]));
console.log("1 2 2".split(" "));
let str = "232wew23244as33";
let res = [];
for (let i = 0; i < str.length; i++) {
  let j = i;
  let temp = "";
  while (parseInt(str[j]) == str[j]) {
    temp += str[j];
    j++;
    i++;
  }
  if (temp.length != 0) res.push(parseInt(temp));
}
let resFunc = function (str, count_sum, SubstrL) {
  let temp;
  for (let i = 0; i < str.length; i++) {
    if (!temp) {
      temp = new Array(SubstrL).fill(0);
      for (let j = i; j < i + count_sum; j++) {
        temp[str[i]]++;
      }
      i = i + SubstrL;
    } else {
      temp[str[i - SubstrL]]--;
      temp[str[i]]++;
    }
    res.push(temp.indexOf(Math.max(...temp)));
  }
};
